package com.mib.browser;

import javax.swing.*;
import java.awt.*;

public class AboutDialog extends JDialog {
    private JLabel jLabel1;
    private JLabel jLabel2;
    private JLabel jLabel3;
    private JLabel jLabel4;
    private JLabel jLabel5;

    public AboutDialog(Frame parent, boolean modal) {
        super(parent, modal);
        this.initComponents(parent);
    }

    private void initComponents(Frame parent) {
        int windowWidth = 345; // 获得窗口宽
        int windowHeight = 128; // 获得窗口高
        Toolkit kit = Toolkit.getDefaultToolkit(); // 定义工具包
        Dimension screenSize = kit.getScreenSize(); // 获取屏幕的尺寸
        int screenWidth = screenSize.width; // 获取屏幕的宽
        int screenHeight = screenSize.height; // 获取屏幕的高

        this.jLabel1 = new JLabel();
        this.jLabel2 = new JLabel();
        this.jLabel3 = new JLabel();
        this.jLabel4 = new JLabel();
        this.jLabel5 = new JLabel();
        this.setTitle("About");
        this.setResizable(false);
        this.jLabel1.setText("ServersCheck MIB Browser");
        this.jLabel2.setText("Version: 0.1");
        this.jLabel3.setIcon(new ImageIcon("res\\logo.gif"));
        this.jLabel3.setOpaque(true);
        this.jLabel4.setText("(C) Copyright 2023 ServersCheck BVBA.");
        this.jLabel5.setText("All Rights Reserved.");
        GroupLayout layout = new GroupLayout(this.getContentPane());
        this.getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(GroupLayout.Alignment.CENTER)
                        .addGroup(layout.createSequentialGroup().addContainerGap()
                                .addComponent(this.jLabel3, -2, 89, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
                                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER, false)
                                                .addComponent(this.jLabel5, -1, -1, 32767)
                                                .addComponent(this.jLabel4, -1, -1, 32767)
                                                .addComponent(this.jLabel2))
                                        .addComponent(this.jLabel1)
                                ).addContainerGap()
                        )
        );
        layout.setVerticalGroup(
                layout.createParallelGroup(GroupLayout.Alignment.CENTER)
                        .addGroup(layout.createSequentialGroup().addContainerGap()
                                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
                                        .addComponent(this.jLabel3, -2, 81, -2)
                                        .addGroup(layout.createSequentialGroup()
                                                .addComponent(this.jLabel1).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(this.jLabel2, -2, 14, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout.createParallelGroup()
                                                        .addGroup(layout.createSequentialGroup().addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 22, 32767)
                                                                .addComponent(this.jLabel5))
                                                        .addGroup(layout.createSequentialGroup()
                                                                .addGap(19, 19, 19)
                                                                .addComponent(this.jLabel4)
                                                        )
                                                )
                                        )
                                ).addContainerGap()));

        this.setLocation(screenWidth / 2 - windowWidth / 2, screenHeight / 2 - windowHeight / 2);
        this.pack();
    }
}
